Always duplicate badchar string into handle to eliminate special cases on
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 9 Jan 2006 17:07:30 +0000 (17:07 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 9 Jan 2006 17:07:30 +0000 (17:07 +0000)
the handle release.

gpsbabel/mkshort.c

index a035062dc4b93f0588794eed3819286eb3f2d2a9..cba30f3e42bd0dcbf3b5262339013a46c60c8b0e 100644 (file)
@@ -85,7 +85,7 @@ mkshort_new_handle()
                QUEUE_INIT(&h->namelist[i]);
 
        h->whitespaceok = 1;
-       h->badchars = DEFAULT_BADCHARS;
+       h->badchars = xstrdup(DEFAULT_BADCHARS);
        h->target_len = DEFAULT_TARGET_LEN;
        h->must_uniq = 1;
        h->defname = xstrdup("WPT");
@@ -278,13 +278,9 @@ setshort_badchars(short_handle h, const char *s)
 {
        mkshort_handle *hdl = (mkshort_handle *) h;
 
-       if ((hdl->badchars != NULL) && (hdl->badchars != DEFAULT_BADCHARS))
+       if ((hdl->badchars != NULL))
                xfree(hdl->badchars);
-       if (s == NULL) {
-               hdl->badchars = DEFAULT_BADCHARS;
-       } else {
-               hdl->badchars = xstrdup(s);
-       }
+       hdl->badchars = xstrdup (s ? s : DEFAULT_BADCHARS);
 }
 
 /*